-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
lib: call normalizeEncoding in fs.writeFileSync and fs.readFileSync #60539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Review requested:
|
9143536 to
121725f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good see next comment
normalizeEncoding has already a short-cut for utf8 and utf-8 (which were directly checked here before), so this should not have any measurable negative effect for those common cases, but optimizes non-common ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks default encoding to be buffer
normalizeEncoding normalizes undefined to 'utf8', but readFileSync does not set options.encoding to a default value at that point, unlike writeFileSync, and the expectation is to read Buffers by default, not strings
121725f to
862df86
Compare
862df86 to
771bd39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eeeh
this also demonstrates how flush option is broken in fast write path
it's does not appear to be the fault of this PR but an existing bug though
upd: #60552
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60539 +/- ##
==========================================
- Coverage 88.58% 88.56% -0.03%
==========================================
Files 704 704
Lines 207839 207844 +5
Branches 40051 40043 -8
==========================================
- Hits 184117 184076 -41
- Misses 15791 15809 +18
- Partials 7931 7959 +28
🚀 New features to boost your workflow:
|
|
CI is going to fail unless #60552 is fixed first, which is though unrelated directly Basically, #60552 fix has to go in first. (Upd: #60553) |
|
@ChALkeR, I appreciate the thorough review and explanation here, thank you so much! |
Fixes #49888 by adding calls to
normalizeEncoding.Benchmarks between #f46152fdb3 and CL from this PR
I am open to suggestions here, but given that in the case of fast paths, the only encoding we care about is utf8, would it perhaps make more sense to have a
isUTF8Encoding()which would return a bool?Reviews and suggestions are much appreciated 🙏🏼